<?php

use yii\helpers\Url;
?>

<form action="<?php echo Url::toRoute('demo/logindo'); ?>" method="post">
    <h2>用户绑定手机号</h2>
    <div class="form-group">
        <label for="exampleInputEmail1">手机号</label>
        <input type="text" class="form-control" id="tel" placeholder="请输入手机号" name="tel">
    </div>
    <div class="form-group">
        <input type="text"  name="phoneinfo">
        <input type="button" id="sendinfo" value="发送验证码">
        <input type="hidden" name="_csrf" value="<?php echo Yii::$app->request->csrfToken ?>">
    </div>
    <button type="submit" class="btn btn-default">完成</button>
</form>
<script src="jquery-3.3.1.js"></script>
<script>
    $(document).on("click","#sendinfo",function(){
        var phone = $("#tel").val()
//        alert(phone)
        $.ajax({
            method:"post",
            url:"duanxin/SendTemplateSMS.php",
            dataType:"json",
            data:{
                phone:phone
            },
            success:function(res){
                console.log(res)
            }
        })
    })

</script>

